package C037;

/**
 * ClassName: C06
 * Package: C037
 * Description:
 *
 * @Author BCXJ
 * @Create 2025/1/23 20:20
 * @Version 1.0
 * @Since 1.0
 */
public class C06 {
    public static void main(String[] args) {

    }
    public static class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }
    public TreeNode trimBST(TreeNode root, int low, int high) {
        if(root == null) {
            return null;
        }

        if(root.val < low) {
            return trimBST(root.right, low, high);
        }

        if(root.val > high) {
            return trimBST(root.left, low, high);
        }

        root.left = trimBST(root.left, low, high);
        root.right = trimBST(root.right, low, high);
        return root;
    }

}
